package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.urgentTeardownResultPojo;
import com.example.pojo.urgentTeardownStandardPojo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * ClassName:urgentTeardownResultMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/10/17 19:01
 * @Version 1.0
 */
@Mapper
public interface urgentTeardownResultMapp {
    @DS("newMscLowCodeFormal")
    void insertSeveralRows(List<urgentTeardownResultPojo> pojos);

    //查询所有特急分解检测结果
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0")
    List<urgentTeardownResultPojo> queryAll();

    //根据分页查询特急分解检测结果
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where " +
            "sys_deleted=0 " +
            "order by create_time ASC " +
            "limit #{startRow}, #{size}")
    List<urgentTeardownResultPojo> queryByPage(Integer startRow, Integer size);
    //查询所有特急分解检测结果总条数
    @DS("newMscLowCodeFormal")
    @Select("SELECT COUNT(*) FROM ddm_urgent_teardown_result where sys_deleted=0")
    Integer queryQuantity();

    //修改一行特急分解检测结果
    @DS("newMscLowCodeFormal")
    @Update("update ddm_urgent_teardown_result " +
            "set " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +
            "process_status=#{process_status}, " +
            "sys_update_user=#{sys_update_user}, "+
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "actual_value=#{actual_value}, " +
            "measuring_picture_person=#{measuring_picture_person}, " +
            "measurement_date=#{measurement_date}, " +
            "file_name=#{file_name}, " +
            "finish=#{finish} "+
            "where id=#{id}")
    void editOneById(urgentTeardownResultPojo pojo);

    //查询特急分解检测结果一个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0 and ${fieldName1}=#{fieldValue1}")
    List<urgentTeardownResultPojo> queryOneField(String fieldName1, String fieldValue1);
    //查询特急分解检测结果二个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0 and ${fieldName1}=#{fieldValue1} and ${fieldName2}=#{fieldValue2}")
    List<urgentTeardownResultPojo> queryTwoFields(String fieldName1, String fieldValue1, String fieldName2, String fieldValue2);
    //查询特急分解检测结果三个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0 and ${fieldName1}=#{fieldValue1} and ${fieldName2}=#{fieldValue2} and ${fieldName3}=#{fieldValue3}")
    List<urgentTeardownResultPojo> queryThreeFields(String fieldName1, String fieldValue1, String fieldName2, String fieldValue2, String fieldName3, String fieldValue3);
    //查询特急分解检测结果四个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0 and ${fieldName1}=#{fieldValue1} and ${fieldName2}=#{fieldValue2} and ${fieldName3}=#{fieldValue3} and ${fieldName4}=#{fieldValue4}")
    List<urgentTeardownResultPojo> queryFourFields(String fieldName1, String fieldValue1, String fieldName2, String fieldValue2, String fieldName3, String fieldValue3, String fieldName4, String fieldValue4);
    //查询特急分解检测结果五个字段为某值的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_urgent_teardown_result where sys_deleted=0 and ${fieldName1}=#{fieldValue1} and ${fieldName2}=#{fieldValue2} and ${fieldName3}=#{fieldValue3} and ${fieldName4}=#{fieldValue4} and ${fieldName5}=#{fieldValue5}")
    List<urgentTeardownResultPojo> queryFiveFields(String fieldName1, String fieldValue1, String fieldName2, String fieldValue2, String fieldName3, String fieldValue3, String fieldName4, String fieldValue4, String fieldName5, String fieldValue5);

    //上传特急分解检测结果照片
    @DS("newMscLowCodeFormal")
    @Update("update ddm_urgent_teardown_result " +
                   "set ${fieldName}=#{fieldValue} where id=#{id}")
    void editOneField(String id, String fieldName, String fieldValue);

    //修改多行特急分解检测结果(录入检测结果)
    @DS("newMscLowCodeFormal")
    void uploadById(@Param("list") List<urgentTeardownResultPojo> pojos);

    // 根据动态条件分页查询特急分解检测结果
    @DS("newMscLowCodeFormal")
    List<urgentTeardownResultPojo> queryByDynamicConditionsWithPagination(Map<String, Object> map);

    // 根据动态条件查询特急分解检测结果总条数
    @DS("newMscLowCodeFormal")
    Integer queryByDynamicConditionsCount(Map<String, Object> map);
}
